import Read_unit_infor
import csv
def process_loadData(str):
    a = []
    with open('demands.csv', 'r') as csvfile:
        reader = csv.reader(csvfile)
        for i, rows in enumerate(reader):
            a.append(rows)
    # print(a)
    unit_infor = Read_unit_infor.get_unit_infor()
    aux_unit_infor = []
    for k in range(0, len(unit_infor)):
        aux_unit_infor.append(unit_infor[k][0])
    res = []
    lingjian_index = []
    for i in range(0, len(a)):
        if str in a[i]:
            res.append(a[i])
    # print(res)
    for i in range(0,len(res)):
        lingjian_index.append(res[i][0])
    # 去重,
    # print(lingjian_index)
    new_list = []
    for i in lingjian_index:
        if i not in new_list:
            new_list.append(i)
    # print(new_list)  # [2, 3, 4, 5, 1]
# 为所有供应商建立一个二维数组，按照，零件供应商编号、零件编号、零件面积
# 它首先是一个new_list*未知数的二维数组
    all_information = []
    for i in range(0,len(new_list)):
        temp = []
        temp.append(new_list[i])
        for j in range(0, len(res)):
            if new_list[i] in res[j]:
                temp.append(res[j][1])
                # 放入res[j][2]之前，进行一个整除
                beichu = aux_unit_infor.index(res[j][1])
                temp.append(int(res[j][2]) / int(unit_infor[beichu][5]))
        all_information.append(temp)
        # print(temp)
    # for i in range(0,len(all_information)):
    print(all_information)
    # print(len(all_information))
    return all_information